#ifndef REGISTERGRAPH_H
#define REGISTERGRAPH_H

#include <QtGui/QWidget>
#include <registerdef.h>

class QVBoxLayout;
class QLineEdit;
class QTimer;
class QDropEvent;
class QDateTime;
class RegisterPlot;
class QwtPlotItem;

namespace Ui {
    class RegisterGraph;
}

class RegisterGraph : public QWidget {
    Q_OBJECT
public:
    RegisterGraph(QWidget *parent = 0);
    ~RegisterGraph();

    void setRegisterList(QList<RegisterDef>* regList);
    void start();
    void stop();

private slots:
    void on_lineEdit_editingFinished();
    void updateData();
    void dragEnterEvent(QDragEnterEvent *event);
    void dropEvent(QDropEvent *event);
    void removeCurve(QwtPlotItem* item);

protected:
    void changeEvent(QEvent *e);

signals:
    void readNeeded(int reg);

private:
    void addRegister(RegisterDef reg);

    Ui::RegisterGraph *m_ui;
    RegisterPlot *ui_plot;
    QList<int> graphedRegisters;
    QList<RegisterDef> *registerList;

    int updateInterval;
    int maxSamples;

    QVBoxLayout *ui_layout;
    QLineEdit *ui_interval;
    QTimer *timer;

    QList<QColor> colors;
};

#endif // REGISTERGRAPH_H
